<template>
	<view>
		<!-- 顶部导航栏 -->
		<view class="header">
			<x-status-bar></x-status-bar>
			<view class="flex-center-between header-navbar">
				<x-back-btn></x-back-btn>
				<view class="u-f-40 common-title">{{ lang_note.likedDetail }}</view>
				<view></view>
			</view>
			<!-- 分割线 -->
			<u-gap height="1" bgColor="rgba(0, 0, 0, 0.07)"></u-gap>
			
			<view class="u-f-32 u-lh-44 font-medio" style="padding: 18rpx 30rpx 28rpx;">{{ lang_common.liked }}{{ total ? `（${ total }）` : '' }}</view>
		</view>
		
		<!-- 用户列表 -->
		<view>
			<mescroll-body height="calc(100vh - 188rpx - var(--status-bar-height))" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
				>
				<view style="padding: 0 30rpx;">
					<view
					v-for="(item, index) in dataList"
					:key="index"
					class="flex-center u-p-b-36 u-m-b-32"
					style="border-bottom: 2rpx solid rgba(151,151,151,.2);"
					>
						<view class="u-avatar-76 clear-flex">
							<x-image :src="showImage(item.avatar, 'logo')"/>
						</view>
						
						<view class="flex-between flex-column u-m-l-14">
							<view class="u-f-28 u-lh-40 font-medio">{{ item.nick || '' }}</view>
							<view class="u-f-26 u-lh-36 u-m-t-4" style="color: #B1B1B1;">{{ dayjs(item.createTime || dayjs()).format('YYYY-MM-DD') }}</view>
						</view>
					</view>
				</view>
				<!-- 留空 -->
				<view style="height: 200rpx"></view>
			</mescroll-body>
		</view>
	</view>
</template>

<script>
	import { notesNotesLikeUserPage } from '@/api/user/notes.js'
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";

	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				notesId: '',
				dataList: [],
				total: 0
			}
		},
		onLoad({ notesId }) {
			this.notesId = notesId
		},
		methods: {
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				let node = this.$refs['mescrollRef']
				notesNotesLikeUserPage({
					pageNumber: page.num,
					pageSize: page.size,
					notesId: this.notesId
				}).then(res => {
					this.total = res.totalRow || 0
					node && node.mescroll.endSuccess(res.list.length);
					if (page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
					this.dataList = this.dataList.concat(res.list); //追加新数据
				}).catch(() => {
					node && node.mescroll.endErr();
				})
			},
			downCallback() {
				let node = this.$refs['mescrollRef']
				node && node.mescroll.resetUpScroll()
			}
		}
	}
</script>

<style scoped lang="scss">
	
</style>
